﻿@using Abp.MultiTenancy
@using Abp.Web.Mvc.Extensions
@using AbpCompanyName.AbpProjectName.MultiTenancy
@model Abp.Application.Services.Dto.ListResultDto<AbpCompanyName.AbpProjectName.MultiTenancy.Dto.TenantListDto>
@{
    ViewBag.ActiveMenu = "Tenants"; //The menu item will be active for this page.
}
@section scripts
{
    @Html.IncludeScript("~/Views/Tenants/Index.js")
}
<div>
    <h1>@L("Tenants")</h1>
    <div class="row">
        <div class="col-md-12">
            <button data-toggle="modal" data-target="#TenantCreateModal" class="btn btn-primary pull-right"><i class="fa fa-plus"></i> @L("CreateNewTenant")</button>
            <table class="table">
                <thead>
                    <tr>
                        <th>@L("TenancyName")</th>
                        <th>@L("Name")</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var tenant in Model.Items)
                    {
                        <tr>
                            <td>@tenant.TenancyName</td>
                            <td>@tenant.Name</td>
                        </tr>
                    }
                </tbody>
            </table>
        </div>
    </div>
</div>

<div class="modal fade" id="TenantCreateModal" tabindex="-1" role="dialog" aria-labelledby="TenantCreateModalLabel" data-backdrop="static">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <form name="tenantCreateForm" role="form" novalidate class="form-validation">
                <div class="modal-header">
                    <h4 class="modal-title">
                        <span>@L("CreateNewTenant")</span>
                    </h4>
                </div>
                <div class="modal-body">

                    <div class="form-group">
                        <label>@L("TenancyName")</label>
                        <input class="form-control" type="text" name="TenancyName" required maxlength="@Tenant.MaxTenancyNameLength" minlength="2">
                    </div>

                    <div class="form-group">
                        <label>@L("Name")</label>
                        <input type="text" name="Name" class="form-control" required maxlength="@Tenant.MaxNameLength">
                    </div>

                    <div class="form-group">
                        <label>@L("DatabaseConnectionString") (@L("Optional"))</label>
                        <input type="text" name="ConnectionString" class="form-control" maxlength="@AbpTenantBase.MaxConnectionStringLength">
                    </div>

                    <div class="form-group">
                        <label>@L("AdminEmailAddress")</label>
                        <input type="email" name="AdminEmailAddress" class="form-control" required maxlength="@AbpCompanyName.AbpProjectName.Users.User.MaxEmailAddressLength">
                    </div>

                    <p>@L("DefaultPasswordIs", AbpCompanyName.AbpProjectName.Users.User.DefaultPassword)</p>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">@L("Cancel")</button>
                    <button type="submit" class="btn btn-primary blue"><i class="fa fa-save"></i> <span>@L("Save")</span></button>
                </div>
            </form>
        </div>
    </div>
</div>
